/* path模块是node当中自带的模块，专用用来处理系统文件，并且能与文件系统进行交互 */
let path = require('path');
// console.log(path);
/* 
{
  resolve: [Function: resolve],
  normalize: [Function: normalize],
  isAbsolute: [Function: isAbsolute],
  join: [Function: join],
  relative: [Function: relative],
  toNamespacedPath: [Function: toNamespacedPath],
  dirname: [Function: dirname],
  basename: [Function: basename],
  extname: [Function: extname],
  format: [Function: bound _format],
  parse: [Function: parse],
  sep: '\\',
  delimiter: ';',
  win32: [Circular],
  posix: {
    resolve: [Function: resolve],
    normalize: [Function: normalize],
    isAbsolute: [Function: isAbsolute],
    join: [Function: join],
    relative: [Function: relative],
    toNamespacedPath: [Function: toNamespacedPath],
    dirname: [Function: dirname],
    basename: [Function: basename],
    extname: [Function: extname],
    format: [Function: bound _format],
    parse: [Function: parse],
    sep: '/',
    delimiter: ':',
    win32: [Circular],
    posix: [Circular],
    _makeLong: [Function: toNamespacedPath]
  },
  _makeLong: [Function: toNamespacedPath]
}


*/
// path.resolve获得相对路径的绝对路径计算
// console.log(path.resolve('zihao.js'));
// D:\a-jinsi-courseware\1.class course\4.w2203A\7.node\node-2203\zihao.js
// console.log(path.resolve('/','zihao.js'));
// D:\zihao.js
// console.log(path.resolve('/test','zihao.js'));
// D:\test\zihao.js
// console.log(path.resolve('/test/xx','yyy','ooo','zihao.js'));
// D:\test\xx\yyy\zihao.js
// D:\test\xx\yyy\ooo\zihao.js
// console.log(path.basename('../../../2. W2104A/1. 轮播图/2.course/1.轮播图.html')); 
// path.basename作用是返回路径的最后一部分
// path.basename参数 参数一：路径，参数二：文件的后缀名 作用可以过滤掉文件的扩展名
// console.log(path.basename('./1.buffer.js','.js'));

// path.dirname 返回的是路径的目录部分
// console.log(path.dirname('../../1.c3h5/day01/1.选择器.html'));//../../1.c3h5/day01
// 返回路径的扩展名部分
// console.log(path.extname('../node-2203/1.buffer.js'));//.js
// console.log(path.extname('../node-2203'))
// path.join() 连接路径的两个或者多个部分
// console.log(path.join('/','xx','yy','zihao.txt'));//\xx\yy\zihao.txt

// path.parse()
let result = path.parse('../../1.c3h5/day01/1.选择器.html');
console.log(result)
/* {
  root: '',  根路径
  dir: '../../1.c3h5/day01',  
  base: '1.选择器.html',
  ext: '.html',
  name: '1.选择器'
} */
let res = path.parse('D:\\xx\\index.html');
console.log(res);
/* 
{
  root: 'D:\\',//D:/
  dir: 'D:\\xx',
  base: 'index.html',
  ext: '.html',
  name: 'index'
}


*/
let test1 = path.basename('D:\\test\\xx\\yyy\\ooo\\zihao.js');
console.log(test1);//zihao.js